package dbmanager

import (
	"time"

	"gorm.io/gorm"
)

// PlayerBase 一个角色一行数据的表基类
type PlayerBase struct {
	PID       uint64 `gorm:"primarykey;column:pid"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

func (this *PlayerBase) GetPID() uint64 {
	return this.PID
}
func (this *PlayerBase) GetCreateAt() time.Time {
	return this.CreatedAt
}

func (this *PlayerBase) IsDeleted() bool {
	return this.DeletedAt.Valid && (this.DeletedAt.Time != time.Time{})
}

func (this *PlayerBase) SetDelete() {
	this.DeletedAt.Time = time.Now()
	this.DeletedAt.Valid = true
}

// 撤销删除
func (this *PlayerBase) RevokeDelete() {
	this.DeletedAt = gorm.DeletedAt{}
}

// 是否支持部分更新
func (this *PlayerBase) GetIsPartial() bool {
	return true
}
